import _fetch from '@/utils/request.js'
// 获取登录Api
export function loginApi (mobile, code) {
  return _fetch({
    url: '/v1_0/authorizations',
    method: 'post',
    needToken: true,
    data: {
      mobile: mobile,
      code: code
    }
  })
}
// 获取验证码Api
export function codeApi (mobile) {
  return _fetch({
    url: '/v1_0/sms/codes/' + mobile,
    needToken: true
  })
}
// 获取所有频道Api
export function channelsApi () {
  return _fetch({
    url: '/v1_0/channels'
  })
}
// 获取当前用户的频道的Api
export function userChannelsApi () {
  return _fetch({
    url: '/v1_0/user/channels',
    headers: {
      'Content-Type': 'application/json'
    },
    needToken: true
  })
}
// 获取文章Api
export function articlesApi (id, time, top) {
  return _fetch({
    url: '/v1_1/articles',
    headers: {
      'Content-Type': 'application/json'
    },
    params: {
      channel_id: id,
      timestamp: time,
      with_top: top
    }
  })
}
export function userInfoApi () {
  return _fetch({
    url: '/v1_0/user/profile',
    headers: {
      'Content-Type': 'application/json'
    },
    needToken: true
  })
}
// 设置用户频道列表
export function setUserChannel (channels) {
  return _fetch({
    url: '/v1_0/user/channels',
    method: 'put',
    needToken: true,
    data: {
      channels
    }
  })
}
// 举报文章
export function reportsApi (id, type, remark) {
  return _fetch({
    url: '/v1_0/article/reports',
    method: 'post',
    headers: {
      'Content-Type': 'application/json'
    },
    data: {
      target: id,
      type: type,
      remark: remark
    },
    needToken: true
  })
}
// 对文章不喜欢
export function dislikeApi (target) {
  return _fetch({
    url: '/v1_0/article/dislikes',
    method: 'post',
    headers: {
      'Content-Type': 'application/json'
    },
    needToken: true,
    data: {
      target: target
    }
  })
}
// 拉黑作者
export function blacklistApi (target) {
  return _fetch({
    url: '/v1_0/user/blacklists',
    method: 'post',
    headers: {
      'Content-Type': 'application/json'
    },
    needToken: true,
    data: {
      target: target
    }
  })
}
